package de.jarnbjo.theora;

public class Constants {

   public static final int CURRENT_ENCODE_VERSION           = 1;
   public static final int HUGE_ERROR                       = 1<<28;  /*  Out of range test value */

   /* Baseline dct height and width. */
   public static final int BLOCK_HEIGHT_WIDTH               = 8;
   public static final int HFRAGPIXELS                      = 8;
   public static final int VFRAGPIXELS                      = 8;

   /* Baseline dct block size */
   public static final int BLOCK_SIZE =
      (BLOCK_HEIGHT_WIDTH * BLOCK_HEIGHT_WIDTH);

   /* Border is for unrestricted mv's */
   public static final int UMV_BORDER                       = 16;
   public static final int STRIDE_EXTRA                     = UMV_BORDER * 2;
   public static final int Q_TABLE_SIZE                     = 64;

   public static final int BASE_FRAME                       = 0;
   public static final int NORMAL_FRAME                     = 1;

   public static final int MAX_MODES                        = 8;
   public static final int MODE_BITS                        = 3;
   public static final int MODE_METHODS                     = 8;
   public static final int MODE_METHOD_BITS                 = 3;

   /* Different key frame types/methods */
   public static final byte DCT_KEY_FRAME                    = 0;

   public static final int KEY_FRAME_CONTEXT                = 5;

   /* Preprocessor defines */
   public static final int MAX_PREV_FRAMES                  = 16;

   /* Number of search sites for a 4-step search (at pixel accuracy) */
   public static final int MAX_SEARCH_SITES                 = 33;

   public static final int VERY_BEST_Q                      = 10;
   public static final double MIN_BPB_FACTOR                = 0.3;
   public static final double MAX_BPB_FACTOR                = 3.0;

   /* Max search distance in half pixel increments */
   public static final int MAX_MV_EXTENT                    = 31;

   public static final int MIN16                            = ((1<<16)-1);
   public static final int SHIFT16                          = (1<<16);

   public static final int MIN_LEGAL_QUANT_ENTRY            = 8;
   public static final int MIN_DEQUANT_VAL                  = 2;
   public static final int IDCT_SCALE_FACTOR                = 2; /* Shift left bits to improve IDCT precision */
   public static final int OLD_SCHEME                       = 1;

   public static final int NUM_HUFF_TABLES                  = 80;
   public static final int DC_HUFF_OFFSET                   = 0;
   public static final int AC_HUFF_OFFSET                   = 16;
   public static final int AC_TABLE_2_THRESH                = 5;
   public static final int AC_TABLE_3_THRESH                = 14;
   public static final int AC_TABLE_4_THRESH                = 27;

   public static final int DC_HUFF_CHOICES                  = 16;
   public static final int DC_HUFF_CHOICE_BITS              = 4;

   public static final int AC_HUFF_CHOICES                  = 16;
   public static final int AC_HUFF_CHOICE_BITS              = 4;

/* Constants assosciated with entropy tokenisation. */
   public static final int MAX_SINGLE_TOKEN_VALUE           = 6;
   public static final int DCT_VAL_CAT2_MIN                 = 3;
   public static final int DCT_VAL_CAT3_MIN                 = 7;
   public static final int DCT_VAL_CAT4_MIN                 = 9;
   public static final int DCT_VAL_CAT5_MIN                 = 13;
   public static final int DCT_VAL_CAT6_MIN                 = 21;
   public static final int DCT_VAL_CAT7_MIN                 = 37;
   public static final int DCT_VAL_CAT8_MIN                 = 69;

   public static final int DCT_EOB_TOKEN                    = 0;
   public static final int DCT_EOB_PAIR_TOKEN               = 1;
   public static final int DCT_EOB_TRIPLE_TOKEN             = 2;
   public static final int DCT_REPEAT_RUN_TOKEN             = 3;
   public static final int DCT_REPEAT_RUN2_TOKEN            = 4;
   public static final int DCT_REPEAT_RUN3_TOKEN            = 5;
   public static final int DCT_REPEAT_RUN4_TOKEN            = 6;

   public static final int DCT_SHORT_ZRL_TOKEN              = 7;
   public static final int DCT_ZRL_TOKEN                    = 8;

   public static final int ONE_TOKEN                        = 9;       /* Special tokens for -1,1,-2,2 */
   public static final int MINUS_ONE_TOKEN                  = 10;
   public static final int TWO_TOKEN                        = 11;
   public static final int MINUS_TWO_TOKEN                  = 12;

   public static final int LOW_VAL_TOKENS                   = (MINUS_TWO_TOKEN + 1);
   public static final int DCT_VAL_CATEGORY3                = (LOW_VAL_TOKENS + 4);
   public static final int DCT_VAL_CATEGORY4                = (DCT_VAL_CATEGORY3 + 1);
   public static final int DCT_VAL_CATEGORY5                = (DCT_VAL_CATEGORY4 + 1);
   public static final int DCT_VAL_CATEGORY6                = (DCT_VAL_CATEGORY5 + 1);
   public static final int DCT_VAL_CATEGORY7                = (DCT_VAL_CATEGORY6 + 1);
   public static final int DCT_VAL_CATEGORY8                = (DCT_VAL_CATEGORY7 + 1);

   public static final int DCT_RUN_CATEGORY1                = (DCT_VAL_CATEGORY8 + 1);
   public static final int DCT_RUN_CATEGORY1B               = (DCT_RUN_CATEGORY1 + 5);
   public static final int DCT_RUN_CATEGORY1C               = (DCT_RUN_CATEGORY1B + 1);
   public static final int DCT_RUN_CATEGORY2                = (DCT_RUN_CATEGORY1C + 1);

   /* 35 */
   public static final int MAX_ENTROPY_TOKENS               = (DCT_RUN_CATEGORY2 + 2);


   public static final int INTERNAL_BLOCK_HEIGHT            = 8;
   public static final int INTERNAL_BLOCK_WIDTH             = 8;


   /* NEW Line search values. */
   public static final int UP                               = 0;
   public static final int DOWN                             = 1;
   public static final int LEFT                             = 2;
   public static final int RIGHT                            = 3;

   public static final int FIRST_ROW                        = 0;
   public static final int NOT_EDGE_ROW                     = 1;
   public static final int LAST_ROW                         = 2;

   public static final int YDIFF_CB_ROWS                    = (INTERNAL_BLOCK_HEIGHT * 3);
   public static final int CHLOCALS_CB_ROWS                 = (INTERNAL_BLOCK_HEIGHT * 3);
   public static final int PMAP_CB_ROWS                     = (INTERNAL_BLOCK_HEIGHT * 3);
   public static final int PSCORE_CB_ROWS                   = (INTERNAL_BLOCK_HEIGHT * 4);

// Status values in block coding map
   public static final int CANDIDATE_BLOCK_LOW              = -2;
   public static final int CANDIDATE_BLOCK                  = -1;
   public static final int BLOCK_NOT_CODED                  = 0;
   public static final int BLOCK_CODED_BAR                  = 3;
   public static final int BLOCK_CODED_SGC                  = 4;
   public static final int BLOCK_CODED_LOW                  = 4;
   public static final int BLOCK_CODED                      = 5;

   public static final int MAX_SEARCH_LINE_LEN              = 7;


   public static final int[] dequantIndex = {
      0,  1,  8,  16,  9,  2,  3, 10,
      17, 24, 32, 25, 18, 11,  4,  5,
      12, 19, 26, 33, 40, 48, 41, 34,
      27, 20, 13,  6,  7, 14, 21, 28,
      35, 42, 49, 56, 57, 50, 43, 36,
      29, 22, 15, 23, 30, 37, 44, 51,
      58, 59, 52, 45, 38, 31, 39, 46,
      53, 60, 61, 54, 47, 55, 62, 63
   };

   public static final int[] qThreshTableV1 = {
      500,  450,  400,  370,  340,  310, 285, 265,
      245,  225,  210,  195,  185,  180, 170, 160,
      150,  145,  135,  130,  125,  115, 110, 107,
      100,   96,   93,   89,   85,   82,  75,  74,
      70,   68,   64,   60,   57,   56,  52,  50,
      49,   45,   44,   43,   40,   38,  37,  35,
      33,   32,   30,   29,   28,   25,  24,  22,
      21,   19,   18,   17,   15,   13,  12,  10
   };

   public static final short[] dcScaleFactorTableV1 = {
      220, 200, 190, 180, 170, 170, 160, 160,
      150, 150, 140, 140, 130, 130, 120, 120,
      110, 110, 100, 100, 90,  90,  90,  80,
      80,  80,  70,  70,  70,  60,  60,  60,
      60,  50,  50,  50,  50,  40,  40,  40,
      40,  40,  30,  30,  30,  30,  30,  30,
      30,  20,  20,  20,  20,  20,  20,  20,
      20,  10,  10,  10,  10,  10,  10,  10
   };

   public static final short[] yCoeffsV1 ={
      16,  11,  10,  16,  24,  40,  51,  61,
      12,  12,  14,  19,  26,  58,  60,  55,
      14,  13,  16,  24,  40,  57,  69,  56,
      14,  17,  22,  29,  51,  87,  80,  62,
      18,  22,  37,  58,  68, 109, 103,  77,
      24,  35,  55,  64,  81, 104, 113,  92,
      49,  64,  78,  87, 103, 121, 120, 101,
      72,  92,  95,  98, 112, 100, 103,  99
   };

   public static final short[] uvCoeffsV1 ={
      17,	18,	24,	47,	99,	99,	99,	99,
      18,	21,	26,	66,	99,	99,	99,	99,
      24,	26,	56,	99,	99,	99,	99,	99,
      47,	66,	99,	99,	99,	99,	99,	99,
      99,	99,	99,	99,	99,	99,	99,	99,
      99,	99,	99,	99,	99,	99,	99,	99,
      99,	99,	99,	99,	99,	99,	99,	99,
      99,	99,	99,	99,	99,	99,	99,	99
   };

   /* Different matrices for different encoder versions */
   public static final short[] interCoeffsV1 ={
      16,  16,  16,  20,  24,  28,  32,  40,
      16,  16,  20,  24,  28,  32,  40,  48,
      16,  20,  24,  28,  32,  40,  48,  64,
      20,  24,  28,  32,  40,  48,  64,  64,
      24,  28,  32,  40,  48,  64,  64,  64,
      28,  32,  40,  48,  64,  64,  64,  96,
      32,  40,  48,  64,  64,  64,  96,  128,
      40,  48,  64,  64,  64,  96,  128, 128
   };

   public static final byte[] extraBitLengthsVP31 = {
      0, 0, 0, 2, 3, 4, 12,3, 6,                 // EOB and Zero-run tokens.
      0, 0, 0, 0,                                // Very low value tokens.
      1, 1, 1, 1, 2, 3, 4, 5, 6, 10,             // Other value tokens
      1, 1, 1, 1, 1, 3, 4,                       // Category 1 runs.
      2, 3,                                      // Category 2 runs.
   };

/* Frequency tables for encoder version < 2 */
   public static final int[][] frequencyCountsVP31 = {
      /* DC Intra bias */
      {  198,    62,    22,    31,    14,     6,     6,   205,     3,
        843,   843,   415,   516,
        660,   509,   412,   347,   560,   779,   941,   930,   661,   377,
        170,   155,    39,     2,     9,    15,    11,
        128,    86,
      },
      {  299,    92,    34,    39,    15,     6,     6,   132,     1,
        851,   851,   484,   485,
        666,   514,   416,   351,   567,   788,   953,   943,   670,   383,
        117,   119,    26,     4,    17,     7,     1,
         93,    56,
      },
      {  367,   115,   42,   47,   16,    6,    6,   105,    1,
        896,   896,   492,   493,
        667,   510,   408,   342,   547,   760,   932,   927,   656,   379,
        114,   103,   10,    3,    6,    2,    1,
        88,   49,
      },
      {  462,   158,   63,   76,   28,    9,    8,   145,    1,
        1140,  1140,   573,   574,
        754,   562,   435,   357,   555,   742,   793,   588,   274,   81,
        154,   117,   13,    6,   12,    2,    1,
        104,   62,
      },
      {  558,   196,   81,   99,   36,   11,    9,   135,    1,
        1300,  1301,   606,   607,
        779,   560,   429,   349,   536,   680,   644,   405,   153,   30,
        171,   120,   12,    5,   14,    3,    1,
        104,   53,
      },
      {  635,   233,   100,   122,   46,   14,   12,   113,    1,
        1414,  1415,   631,   631,
        785,   555,   432,   335,   513,   611,   521,   284,   89,   13,
        170,   113,   10,    5,   14,    3,    1,
        102,   62,
      },
      {  720,   276,   119,   154,   62,   20,   16,   101,    1,
        1583,  1583,   661,   661,
        794,   556,   407,   318,   447,   472,   343,   153,   35,    1,
        172,   115,   11,    7,   14,    3,    1,
        112,   70,
      },
      {  853,   326,   144,   184,   80,   27,   19,   52,    1,
        1739,  1740,   684,   685,
        800,   540,   381,   277,   364,   352,   218,   78,   13,    1,
        139,   109,    9,    6,   20,    2,    1,
        94,   50,
      },

      /* DC Inter Bias */
      {  490,   154,   57,   53,   10,    2,    1,   238,   160,
        1391,  1390,   579,   578,
        491,   273,   172,   118,   152,   156,   127,   79,   41,   39,
        712,   547,   316,   125,   183,   306,   237,
        451,   358,
      },
      {  566,   184,   70,   65,   11,    2,    1,   235,   51,
        1414,  1414,   599,   598,
        510,   285,   180,   124,   157,   161,   131,   82,   42,   40,
        738,   551,   322,   138,   195,   188,   93,
        473,   365,
      },
      {  711,   261,   111,   126,   27,    4,    1,   137,   52,
        1506,  1505,   645,   645,
        567,   316,   199,   136,   172,   175,   142,   88,   45,   48,
        548,   449,   255,   145,   184,   174,   121,
        260,   227,
      },
      {  823,   319,   144,   175,   43,    7,    1,   53,   42,
        1648,  1648,   653,   652,
        583,   329,   205,   139,   175,   176,   139,   84,   44,   34,
        467,   389,   211,   137,   181,   186,   107,
        106,   85,
      },
      {  948,   411,   201,   276,   85,   16,    2,   39,   33,
        1778,  1777,   584,   583,
        489,   265,   162,   111,   140,   140,   108,   64,   38,   23,
        428,   356,   201,   139,   186,   165,   94,
        78,   63,
      },
      {  1002,   470,   248,   386,   153,   39,    6,   23,   23,
        1866,  1866,   573,   573,
        467,   249,   155,   103,   130,   128,   94,   60,   38,   14,
        323,   263,   159,   111,   156,   153,   74,
        46,   34,
      },
      {  1020,   518,   291,   504,   242,   78,   18,   14,   14,
        1980,  1979,   527,   526,
        408,   219,   132,   87,   110,   104,   79,   55,   31,    7,
        265,   213,   129,   91,   131,   111,   50,
        31,   20,
      },
      {  1018,   544,   320,   591,   338,   139,   47,    5,    2,
        2123,  2123,   548,   547,
        414,   212,   126,   83,   101,   96,   79,   60,   23,    1,
        120,   97,   55,   39,   60,   38,   15,
        11,    8,
      },

      /* AC INTRA Tables  */
      /* AC Intra bias group 1 tables */
      {  242,   62,   22,   20,    4,    1,    1,   438,    1,
        593,   593,   489,   490,
        657,   580,   471,   374,   599,   783,   869,   770,   491,   279,
        358,   144,   82,   54,   49,   70,    5,
        289,   107,
      },
      {  317,   95,   38,   41,    8,    1,    1,   479,    1,
        653,   654,   500,   501,
        682,   611,   473,   376,   582,   762,   806,   656,   358,   155,
        419,   162,   86,   58,   36,   34,    1,
        315,   126,
      },
      {  382,   121,   49,   59,   15,    3,    1,   496,    1,
        674,   674,   553,   554,
        755,   636,   487,   391,   576,   718,   701,   488,   221,   72,
        448,   161,   107,   56,   37,   29,    1,
        362,   156,
      },
      {  415,   138,   57,   73,   21,    5,    1,   528,    1,
        742,   741,   562,   563,
        753,   669,   492,   388,   563,   664,   589,   340,   129,   26,
        496,   184,   139,   71,   48,   33,    2,
        387,   166,
      },
      {  496,   170,   73,   94,   31,    8,    2,   513,    1,
        855,   855,   604,   604,
        769,   662,   477,   356,   486,   526,   381,   183,   51,    5,
        590,   214,   160,   85,   60,   39,    3,
        427,   203,
      },
      {  589,   207,   89,   116,   40,   13,    3,   491,    1,
        919,   919,   631,   631,
        769,   633,   432,   308,   408,   378,   247,   94,   17,    1,
        659,   247,   201,   105,   73,   51,    3,
        466,   242,
      },
      {  727,   266,   115,   151,   49,   17,    6,   439,    1,
        977,   977,   642,   642,
        718,   572,   379,   243,   285,   251,   133,   40,    1,    1,
        756,   287,   253,   126,   94,   66,    4,
        492,   280,
      },
      {  940,   392,   180,   247,   82,   30,   14,   343,    1,
        1064,  1064,   615,   616,
        596,   414,   235,   146,   149,   108,   41,    1,    1,    1,
        882,   314,   346,   172,   125,   83,    6,
        489,   291,
      },
      /* AC Inter bias group 1 tables */
      {  440,   102,   33,   23,    2,    1,    1,   465,   85,
        852,   852,   744,   743,
        701,   496,   297,   193,   225,   200,   129,   58,   18,    2,
        798,   450,   269,   202,   145,   308,   154,
        646,   389,
      },
      {  592,   151,   53,   43,    6,    1,    1,   409,   34,
        875,   875,   748,   747,
        723,   510,   305,   196,   229,   201,   130,   59,   18,    2,
        800,   436,   253,   185,   115,   194,   88,
        642,   368,
      },
      {  759,   222,   86,   85,   17,    2,    1,   376,   46,
        888,   888,   689,   688,
        578,   408,   228,   143,   165,   141,   84,   35,    7,    1,
        878,   488,   321,   244,   147,   266,   124,
        612,   367,
      },
      {  912,   298,   122,   133,   34,    7,    1,   261,   44,
        1092,  1091,   496,   496,
        409,   269,   150,   95,   106,   87,   49,   16,    1,    1,
        1102,   602,   428,   335,   193,   323,   157,
        423,   253,
      },
      {  1072,   400,   180,   210,   60,   16,    3,   210,   40,
        1063,  1063,   451,   451,
        345,   221,   121,   73,   79,   64,   31,    6,    1,    1,
        1105,   608,   462,   358,   202,   330,   155,
        377,   228,
      },
      {  1164,   503,   254,   330,   109,   34,    9,   167,   35,
        1038,  1037,   390,   390,
        278,   170,   89,   54,   56,   40,   13,    1,    1,    1,
        1110,   607,   492,   401,   218,   343,   141,
        323,   192,
      },
      {  1173,   583,   321,   486,   196,   68,   23,   124,   23,
        1037,  1037,   347,   346,
        232,   139,   69,   40,   37,   20,    2,    1,    1,    1,
        1128,   584,   506,   410,   199,   301,   113,
        283,   159,
      },
      {  1023,   591,   366,   699,   441,   228,   113,   79,    5,
        1056,  1056,   291,   291,
        173,   96,   38,   19,    8,    1,    1,    1,    1,    1,
        1187,   527,   498,   409,   147,   210,   56,
        263,   117,
      },

      /* AC Intra bias group 2 tables */
      {  311,   74,   27,   27,    5,    1,    1,   470,   24,
        665,   667,   637,   638,
        806,   687,   524,   402,   585,   679,   609,   364,   127,   20,
        448,   210,   131,   76,   52,   111,   19,
        393,   195,
      },
      {  416,   104,   39,   38,    8,    1,    1,   545,   33,
        730,   731,   692,   692,
        866,   705,   501,   365,   495,   512,   387,   168,   39,    2,
        517,   240,   154,   86,   64,   127,   19,
        461,   247,
      },
      {  474,   117,   43,   42,    9,    1,    1,   560,   40,
        783,   783,   759,   760,
        883,   698,   466,   318,   404,   377,   215,   66,    7,    1,
        559,   259,   176,   110,   87,   170,   22,
        520,   278,
      },
      {  582,   149,   53,   53,   12,    2,    1,   473,   39,
        992,   993,   712,   713,
        792,   593,   373,   257,   299,   237,   114,   25,    1,    1,
        710,   329,   221,   143,   116,   226,   26,
        490,   259,
      },
      {  744,   210,   78,   77,   16,    2,    1,   417,   37,
        1034,  1035,   728,   728,
        718,   509,   296,   175,   184,   122,   42,    3,    1,    1,
        791,   363,   255,   168,   145,   311,   35,
        492,   272,
      },
      {  913,   291,   121,   128,   28,    4,    1,   334,   40,
        1083,  1084,   711,   712,
        624,   378,   191,   107,   95,   50,    7,    1,    1,    1,
        876,   414,   288,   180,   164,   382,   39,
        469,   275,
      },
      {  1065,   405,   184,   216,   53,    8,    1,   236,   36,
        1134,  1134,   685,   686,
        465,   253,   113,   48,   41,    9,    1,    1,    1,    1,
        965,   451,   309,   179,   166,   429,   53,
        414,   249,
      },
      {  1148,   548,   301,   438,   160,   42,    6,   84,   17,
        1222,  1223,   574,   575,
        272,   111,   23,    6,    2,    1,    1,    1,    1,    1,
        1060,   502,   328,   159,   144,   501,   54,
        302,   183,
      },
      /* AC Inter bias group 2 tables */
      {  403,   80,   24,   17,    1,    1,    1,   480,   90,
        899,   899,   820,   819,
        667,   413,   228,   133,   139,   98,   42,   10,    1,    1,
        865,   470,   316,   222,   171,   419,   213,
        645,   400,
      },
      {  698,   169,   59,   49,    6,    1,    1,   414,   101,
        894,   893,   761,   761,
        561,   338,   171,   96,   97,   64,   26,    6,    1,    1,
        896,   494,   343,   239,   192,   493,   215,
        583,   366,
      },
      {  914,   255,   94,   80,   10,    1,    1,   345,   128,
        935,   935,   670,   671,
        415,   222,   105,   55,   51,   30,   10,    1,    1,    1,
        954,   530,   377,   274,   232,   641,   295,
        456,   298,
      },
      {  1103,   359,   146,   135,   20,    1,    1,   235,   119,
        1042,  1042,   508,   507,
        293,   146,   65,   33,   30,   16,    4,    1,    1,    1,
        1031,   561,   407,   296,   265,   813,   317,
        301,   192,
      },
      {  1255,   504,   238,   265,   51,    5,    1,   185,   113,
        1013,  1013,   437,   438,
        212,   92,   41,   18,   15,    6,    1,    1,    1,    1,
        976,   530,   386,   276,   260,   927,   357,
        224,   148,
      },
      {  1292,   610,   332,   460,   127,   16,    1,   136,   99,
        1014,  1015,   384,   384,
        153,   65,   25,   11,    6,    1,    1,    1,    1,    1,
        942,   487,   343,   241,   238,   970,   358,
        174,   103,
      },
      {  1219,   655,   407,   700,   280,   55,    2,   100,   60,
        1029,  1029,   337,   336,
        119,   43,   11,    3,    2,    1,    1,    1,    1,    1,
        894,   448,   305,   199,   213,  1005,   320,
        136,   77,
      },
      {  1099,   675,   435,   971,   581,   168,   12,   37,   16,
        1181,  1081,   319,   318,
        66,   11,    6,    1,    1,    1,    1,    1,    1,    1,
        914,   370,   235,   138,   145,   949,   128,
        94,   41,
      },

      /* AC Intra bias group 3 tables */
      {  486,   112,   39,   34,    6,    1,    1,   541,   67,
        819,   818,   762,   763,
        813,   643,   403,   280,   332,   295,   164,   53,    6,    1,
        632,   294,   180,   131,   105,   208,   109,
        594,   295,
      },
      {  723,   191,   69,   65,   12,    1,    1,   445,   79,
        865,   865,   816,   816,
        750,   515,   290,   172,   184,   122,   46,    5,    1,    1,
        740,   340,   213,   165,   129,   270,   168,
        603,   326,
      },
      {  884,   264,   102,   103,   21,    3,    1,   382,   68,
        897,   897,   836,   836,
        684,   427,   227,   119,   119,   70,   16,    1,    1,    1,
        771,   367,   234,   184,   143,   272,   178,
        555,   326,
      },
      {  1028,   347,   153,   161,   36,    8,    1,   251,   44,
        1083,  1084,   735,   735,
        541,   289,   144,   77,   57,   23,    3,    1,    1,    1,
        926,   422,   270,   215,   176,   301,   183,
        443,   248,
      },
      {  1155,   465,   224,   264,   71,   14,    3,   174,   27,
        1110,  1111,   730,   731,
        429,   206,   79,   30,   19,    4,    1,    1,    1,    1,
        929,   443,   279,   225,   194,   298,   196,
        354,   223,
      },
      {  1191,   576,   296,   415,   144,   36,    8,   114,   16,
        1162,  1162,   749,   749,
        338,   108,   29,    8,    5,    1,    1,    1,    1,    1,
        947,   458,   273,   207,   194,   248,   145,
        258,   152,
      },
      {  1169,   619,   366,   603,   247,   92,   23,   46,    1,
        1236,  1236,   774,   775,
        191,   35,   14,    1,    1,    1,    1,    1,    1,    1,
        913,   449,   260,   214,   194,   180,   82,
        174,   98,
      },
      {  1006,   537,   381,   897,   504,   266,   101,   39,    1,
        1307,  1307,   668,   667,
        116,    3,    1,    1,    1,    1,    1,    1,    1,    1,
        1175,   261,   295,   70,   164,   107,   31,
        10,   76,
      },
      /* AC Inter bias group 3 tables */
      {  652,   156,   53,   43,    5,    1,    1,   368,   128,
        983,   984,   825,   825,
        583,   331,   163,   88,   84,   48,   15,    1,    1,    1,
        870,   480,   316,   228,   179,   421,   244,
        562,   349,
      },
      {  988,   280,   104,   87,   12,    1,    1,   282,   194,
        980,   981,   738,   739,
        395,   189,   80,   37,   31,   12,    2,    1,    1,    1,
        862,   489,   333,   262,   214,   600,   446,
        390,   260,
      },
      {  1176,   399,   165,   154,   24,    2,    1,   218,   224,
        1017,  1018,   651,   651,
        280,   111,   42,   16,    9,    3,    1,    1,    1,    1,
        787,   469,   324,   269,   229,   686,   603,
        267,   194,
      },
      {  1319,   530,   255,   268,   47,    4,    1,   113,   183,
        1149,  1150,   461,   461,
        173,   58,   17,    5,    3,    1,    1,    1,    1,    1,
        768,   450,   305,   261,   221,   716,   835,
        136,   97,
      },
      {  1362,   669,   355,   465,   104,    9,    1,   76,   153,
        1253,  1253,   398,   397,
        102,   21,    5,    1,    1,    1,    1,    1,    1,    1,
        596,   371,   238,   228,   196,   660,   954,
        68,   53,
      },
      {  1354,   741,   446,   702,   174,   15,    1,   38,   87,
        1498,  1498,   294,   294,
        43,    7,    1,    1,    1,    1,    1,    1,    1,    1,
        381,   283,   165,   181,   155,   544,  1039,
        25,   21,
      },
      {  1262,   885,   546,   947,   263,   18,    1,   18,   27,
        1908,  1908,   163,   162,
        14,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        195,   152,   83,   125,   109,   361,   827,
        7,    5,
      },
      {  2539,   951,   369,   554,   212,   18,    1,    1,    1,
        2290,  2289,   64,   64,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        18,   18,    9,   55,   36,   184,   323,
        1,    1,
      },


      /* AC Intra bias group 4 tables */
      {  921,   264,   101,   100,   19,    2,    1,   331,   98,
        1015,  1016,   799,   799,
        512,   269,   119,   60,   50,   17,    1,    1,    1,    1,
        841,   442,   307,   222,   182,   493,   256,
        438,   310,
      },
      {  1147,   412,   184,   206,   50,    6,    1,   242,   141,
        977,   976,   808,   807,
        377,   135,   40,   10,    7,    1,    1,    1,    1,    1,
        788,   402,   308,   223,   205,   584,   406,
        316,   227,
      },
      {  1243,   504,   238,   310,   79,   11,    1,   184,   150,
        983,   984,   814,   813,
        285,   56,   10,    1,    1,    1,    1,    1,    1,    1,
        713,   377,   287,   217,   180,   615,   558,
        208,   164,
      },
      {  1266,   606,   329,   484,   161,   27,    1,   79,   92,
        1187,  1188,   589,   588,
        103,   10,    1,    1,    1,    1,    1,    1,    1,    1,
        680,   371,   278,   221,   244,   614,   728,
        80,   62,
      },
      {  1126,   828,   435,   705,   443,   90,    8,   10,   55,
        1220,  1219,   350,   350,
        28,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        602,   330,   222,   168,   158,   612,   919,
        104,    5,
      },
      {  1210,   506,  1014,   926,   474,   240,    4,    1,    44,
        1801,  1801,   171,   171,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        900,   132,    36,    11,    47,   191,   316,
        2,    1,
      },
      {  1210,   506,  1014,   926,   474,   240,    4,    1,    44,
        1801,  1801,   171,   171,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        900,   132,    36,    11,    47,   191,   316,
        2,    1,
      },
      {  1210,   506,  1014,   926,   474,   240,    4,    1,    44,
        1801,  1801,   171,   171,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        900,   132,    36,    11,    47,   191,   316,
        2,    1,
      },
      /* AC Inter bias group 4 tables */
      {  1064,   325,   129,   117,    20,    2,    1,   266,   121,
        1000,  1000,   706,   706,
        348,   162,    67,    32,    25,    11,    1,    1,    1,    1,
        876,   513,   363,   274,   225,   627,   384,
        370,   251,
      },
      {  1311,   517,   238,   254,    45,    3,    1,   188,   160,
        1070,  1070,   635,   635,
        239,    85,    30,    11,    6,    1,    1,    1,    1,    1,
        744,   420,   313,   239,   206,   649,   541,
        221,   155,
      },
      {  1394,   632,   322,   385,    78,    7,    1,   134,   152,
        1163,  1164,   607,   607,
        185,    51,    12,    3,    1,    1,    1,    1,    1,    1,
        631,   331,   275,   203,   182,   604,   620,
        146,    98,
      },
      {  1410,   727,   407,   546,   146,    19,    1,    67,    88,
        1485,  1486,   419,   418,
        103,    18,    3,    1,    1,    1,    1,    1,    1,    1,
        555,   261,   234,   164,   148,   522,   654,
         67,    39,
      },
      {  1423,   822,   492,   719,   216,    22,    1,    28,    59,
        1793,  1793,   323,   324,
        37,    2,    1,    1,    1,    1,    1,    1,    1,    1,
        376,   138,   158,   102,   119,   400,   604,
        28,    9,
      },
      {  1585,   923,   563,   918,   207,    25,    1,    5,    20,
        2229,  2230,   172,   172,
        7,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        191,    40,    56,    22,    65,   243,   312,
        2,    1,
      },
      {  2225,  1100,   408,   608,   133,    8,    1,    1,    1,
        2658,  2658,    25,    24,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        8,    1,    1,    1,    1,   125,    16,
        1,    1,
      },
      {  2539,   951,   369,   554,   212,    18,    1,    1,    1,
        2290,  2289,    64,    64,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        18,    18,    9,    55,    36,   184,   323,
        1,    1,
      },
   };

   /* New baseline frequency tables for encoder version >= 2 */
   public static final int[][] frequencyCountsVP33 = {
      /* DC Intra bias  */
      {  272,    84,    31,    36,    10,    2,    1,    92,    1,
        701,   872,   410,   478,
        630,   502,   417,   356,   582,   824,   985,   965,   697,   606,
        125,   119,    40,    3,    9,    15,    10,
        73,    37,
      },
      {  311,   107,    41,    51,    18,    4,    2,   120,    1,
        824,  1037,   468,   541,
        714,   555,   451,   374,   595,   819,   929,   817,   474,   220,
        172,   142,    27,    4,    9,    10,    2,
        98,    48,
      },
      {  353,   125,    49,    66,    24,    6,    2,   124,    1,
        926,  1172,   512,   594,
        766,   581,   458,   379,   590,   789,   849,   665,   306,    80,
        204,   147,    25,    5,    12,    9,    2,
        108,    54,
      },
      {  392,   141,    57,    75,    31,    7,    4,   138,    1,
        1050,  1321,   559,   649,
        806,   594,   460,   372,   568,   727,   710,   475,   155,    19,
        251,   174,    27,    7,    16,    8,    2,
        126,    62,
      },
      {  455,   168,    66,    87,    39,    10,    6,   124,    2,
        1143,  1455,   592,   692,
        824,   596,   453,   361,   542,   657,   592,   329,    78,    5,
        269,   184,    27,    9,    19,    7,    2,
        127,    66,
      },
      {  544,   201,    80,   102,    45,    11,    6,    99,    1,
        1236,  1587,   610,   720,
        833,   590,   444,   348,   506,   588,   487,   226,    39,    2,
        253,   178,    27,    10,    20,    7,    2,
        118,    65,
      },
      {  649,   241,    98,   121,    54,    14,    8,    84,    1,
        1349,  1719,   634,   763,
        847,   583,   428,   323,   456,   492,   349,   120,    13,    1,
        231,   170,    24,    8,    19,    7,    1,
        109,    67,
      },
      {  824,   304,   129,   158,    66,    19,    10,    44,    2,
        1476,  1925,   644,   794,
        838,   559,   396,   289,   392,   384,   223,    53,    3,    1,
        159,   121,    17,    6,    16,    6,    2,
        69,    53,
      },

      /* DC Inter Bias */
      {  534,   174,    71,    68,    10,    1,    1,    68,   119,
        1674,  1526,   560,   536,
        539,   331,   229,   168,   233,   262,   231,   149,    71,    51,
        629,   530,   284,   126,   182,   208,   184,
        148,    87,
      },
      {  594,   195,    77,    71,    9,    1,    1,    47,    89,
        1723,  1592,   595,   570,
        574,   351,   241,   176,   243,   271,   234,   144,    65,    37,
        534,   449,   240,   117,   167,   277,   153,
        96,    54,
      },
      {  642,   213,    88,    83,    12,    1,    1,    40,    80,
        1751,  1630,   621,   600,
        598,   367,   250,   183,   251,   276,   235,   143,    62,    28,
        485,   397,   212,   110,   161,   193,   141,
        84,    48,
      },
      {  693,   258,   114,   131,    27,    3,    1,    44,    79,
        1794,  1644,   550,   533,
        518,   314,   213,   154,   209,   223,   174,    97,    40,    14,
        584,   463,   236,   138,   196,   249,   143,
        94,    54,
      },
      {  758,   303,   144,   189,    53,    8,    1,    37,    69,
        1842,  1732,   513,   504,
        478,   287,   191,   137,   182,   186,   137,    72,    31,    6,
        589,   469,   199,   128,   177,   264,   161,
        89,    49,
      },
      {  817,   344,   170,   243,    84,    18,    2,    30,    65,
        1836,  1733,   518,   511,
        477,   281,   185,   130,   169,   166,   117,    59,    25,    3,
        572,   450,   185,   121,   173,   232,   146,
        80,    43,
      },
      {  865,   389,   204,   322,   139,    42,    9,    26,    51,
        1848,  1766,   531,   522,
        477,   275,   177,   122,   153,   144,    97,    50,    16,    1,
        485,   378,   167,   115,   164,   203,   128,
        74,    42,
      },
      {  961,   447,   243,   407,   196,    74,    26,    12,    34,
        2003,  1942,   571,   565,
        494,   278,   173,   116,   141,   129,    85,    44,    8,    1,
        285,   223,   101,    66,   104,   120,    74,
        35,    22,
      },

      /* AC INTRA Tables  */
      /* AC Intra bias group 1 tables */
      {  245,    68,    25,    28,    5,    1,    1,   359,    4,
        910,   904,   570,   571,
        766,   620,   478,   375,   554,   684,   652,   441,   182,    30,
        535,   206,   118,    77,    69,    90,    16,
        299,   100,
      },
      {  302,    86,    32,    36,    8,    1,    1,   362,    3,
        974,   968,   599,   599,
        774,   635,   469,   365,   528,   628,   557,   337,   118,    14,
        577,   219,   136,    82,    69,    65,    13,
        317,   112,
      },
      {  348,   102,    39,    44,    9,    2,    1,   363,    3,
        1062,  1055,   607,   609,
        787,   626,   457,   348,   494,   550,   452,   233,    60,    2,
        636,   244,   159,    92,    74,    68,    12,
        327,   119,
      },
      {  400,   121,    47,    51,    11,    2,    1,   366,    3,
        1109,  1102,   620,   622,
        786,   624,   450,   331,   459,   490,   366,   163,    29,    1,
        673,   257,   175,    98,    77,    63,    14,
        344,   131,
      },
      {  470,   151,    59,    67,    15,    3,    1,   354,    4,
        1198,  1189,   640,   643,
        769,   603,   410,   294,   386,   381,   240,    78,    5,    1,
        746,   282,   205,   113,    87,    64,    15,
        368,   145,
      },
      {  553,   189,    77,    94,    24,    6,    1,   347,    4,
        1244,  1232,   650,   653,
        739,   551,   360,   249,   303,   261,   129,    24,    1,    1,
        828,   313,   245,   135,   108,    77,    17,
        403,   169,
      },
      {  701,   253,   109,   140,    42,    12,    2,   350,    6,
        1210,  1197,   652,   647,
        673,   495,   299,   189,   211,   151,    50,    2,    1,    1,
        892,   336,   284,   162,   134,   101,    25,
        455,   205,
      },
      {  924,   390,   180,   248,    85,    31,    13,   286,    14,
        1242,  1206,   601,   577,
        519,   342,   175,   100,    85,    36,    1,    1,    1,    1,
        1031,   348,   346,   204,   166,   131,    34,
        473,   197,
      },
      /* AC Inter bias group 1 tables */
      {  459,   128,    50,    48,    8,    1,    1,   224,    69,
        1285,  1227,   587,   565,
        573,   406,   261,   180,   228,   213,   130,    47,    11,    3,
        1069,   540,   309,   231,   147,   279,   157,
        383,   165,
      },
      {  524,   155,    62,    64,    14,    2,    1,   209,    63,
        1345,  1288,   523,   507,
        515,   358,   225,   153,   183,   160,    87,    29,    7,    2,
        1151,   591,   365,   282,   179,   308,   133,
        344,   157,
      },
      {  588,   181,    75,    81,    19,    3,    1,   204,    68,
        1344,  1288,   517,   503,
        505,   346,   216,   141,   169,   139,    71,    21,    5,    1,
        1146,   584,   366,   286,   170,   298,   153,
        342,   157,
      },
      {  634,   196,    82,    89,    22,    4,    1,   194,    60,
        1356,  1312,   515,   502,
        489,   331,   199,   127,   145,   111,    51,    14,    3,    1,
        1156,   589,   393,   300,   182,   285,   144,
        340,   159,
      },
      {  715,   231,    98,   113,    31,    7,    1,   181,    57,
        1345,  1303,   498,   490,
        448,   291,   166,   101,   106,    75,    30,    9,    1,    1,
        1175,   584,   416,   321,   209,   333,   164,
        330,   159,
      },
      {  825,   283,   125,   149,    44,    11,    2,   160,    59,
        1343,  1308,   476,   469,
        405,   247,   131,    75,    76,    47,    18,    5,    1,    1,
        1192,   579,   432,   332,   217,   327,   176,
        320,   154,
      },
      {  961,   361,   170,   215,    70,    20,    5,   161,    55,
        1250,  1218,   463,   460,
        354,   204,   101,    52,    48,    28,    11,    1,    1,    1,
        1172,   570,   449,   350,   222,   332,   169,
        338,   174,
      },
      {  1139,   506,   266,   387,   156,    57,    26,   114,    48,
        1192,  1170,   366,   366,
        226,   113,    47,    22,    22,    12,    1,    1,    1,    1,
        1222,   551,   462,   391,   220,   322,   156,
        290,   136,
      },

      /* AC Intra bias group 2 tables */
      {  245,    49,    15,    11,    1,    1,    1,   332,    38,
        1163,  1162,   685,   683,
        813,   623,   437,   318,   421,   424,   288,   109,    14,    1,
        729,   303,   179,   112,    87,   199,    46,
        364,   135,
      },
      {  305,    67,    22,    17,    2,    1,    1,   329,    39,
        1250,  1245,   706,   705,
        801,   584,   385,   267,   330,   296,   165,    40,    3,    1,
        798,   340,   206,   131,   108,   258,    52,
        382,   154,
      },
      {  356,    82,    28,    23,    3,    1,    1,   312,    42,
        1340,  1334,   701,   703,
        770,   545,   346,   227,   269,   223,   100,    17,    1,    1,
        846,   359,   222,   142,   120,   284,    55,
        379,   157,
      },
      {  402,    95,    33,    30,    4,    1,    1,   300,    43,
        1379,  1371,   710,   714,
        724,   486,   289,   182,   202,   144,    47,    5,    1,    1,
        908,   394,   250,   161,   141,   350,    60,
        391,   171,
      },
      {  499,   122,    44,    42,    7,    1,    1,   267,    45,
        1439,  1436,   690,   694,
        628,   385,   213,   122,   117,    62,    14,    1,    1,    1,
        992,   441,   288,   187,   167,   446,    82,
        378,   176,
      },
      {  641,   168,    62,    60,    12,    1,    1,   247,    49,
        1435,  1436,   662,   669,
        527,   298,   142,    71,    55,    22,    3,    1,    1,    1,
        1036,   470,   319,   208,   193,   548,   106,
        362,   184,
      },
      {  860,   274,   111,   113,    23,    4,    1,   229,    59,
        1331,  1323,   629,   645,
        419,   192,    72,    30,    19,    6,    1,    1,    1,    1,
        1022,   478,   339,   225,   213,   690,   142,
        342,   198,
      },
      {  1059,   437,   218,   285,    84,    17,    2,   152,    44,
        1284,  1313,   530,   561,
        212,    66,    17,    6,    3,    1,    1,    1,    1,    1,
        1034,   485,   346,   226,   207,   819,   185,
        248,   145,
      },
      /* AC Inter bias group 2 tables */
      {  407,    93,    31,    24,    2,    1,    1,   232,   108,
        1365,  1349,   581,   578,
        498,   305,   170,   100,   103,    67,    24,    5,    1,    1,
        1175,   604,   393,   268,   209,   506,   217,
        379,   193,
      },
      {  521,   129,    46,    39,    4,    1,    1,   199,   116,
        1419,  1403,   543,   540,
        446,   263,   138,    78,    75,    44,    13,    2,    1,    1,
        1201,   605,   392,   267,   214,   533,   252,
        334,   167,
      },
      {  575,   144,    52,    46,    6,    1,    1,   193,   124,
        1394,  1384,   528,   528,
        406,   227,   112,    59,    54,    28,    7,    1,    1,    1,
        1210,   621,   412,   284,   235,   604,   265,
        320,   167,
      },
      {  673,   174,    64,    59,    9,    1,    1,   177,   128,
        1392,  1385,   499,   499,
        352,   183,    85,    42,    35,    16,    3,    1,    1,    1,
        1210,   626,   418,   289,   246,   675,   297,
        292,   158,
      },
      {  804,   225,    85,    77,    12,    1,    1,   150,   129,
        1387,  1384,   455,   455,
        277,   129,    53,    23,    17,    7,    1,    1,    1,    1,
        1212,   635,   433,   306,   268,   760,   313,
        249,   137,
      },
      {  975,   305,   123,   117,    20,    2,    1,   135,   140,
        1312,  1310,   401,   399,
        201,    80,    28,    11,    8,    2,    1,    1,    1,    1,
        1162,   623,   439,   314,   283,   906,   368,
        203,   121,
      },
      {  1205,   452,   208,   231,    50,    6,    1,   123,   149,
        1161,  1164,   370,   370,
        137,    45,    14,    4,    2,    1,    1,    1,    1,    1,
        1047,   562,   413,   300,   277,  1020,   404,
        168,   105,
      },
      {  1297,   662,   389,   574,   200,    39,    4,    55,   120,
        1069,  1076,   273,   265,
        66,    14,    2,    1,    1,    1,    1,    1,    1,    1,
        930,   475,   345,   249,   236,  1124,   376,
        91,    56,
      },

      /* AC Intra bias group 3 tables */
      {  278,    55,    17,    12,    1,    1,    1,   288,    71,
        1315,  1304,   725,   724,
        733,   506,   307,   195,   225,   175,    77,    12,    1,    1,
        904,   414,   246,   170,   126,   290,   205,
        423,   185,
      },
      {  382,    80,    26,    21,    2,    1,    1,   239,    64,
        1442,  1429,   706,   701,
        664,   420,   239,   146,   152,   105,    34,    2,    1,    1,
        975,   440,   263,   185,   140,   332,   229,
        397,   169,
      },
      {  451,    97,    32,    27,    4,    1,    1,   223,    75,
        1462,  1454,   682,   680,
        574,   343,   179,   101,    98,    54,    9,    1,    1,    1,
        1031,   482,   293,   210,   163,   400,   297,
        384,   181,
      },
      {  551,   128,    43,    37,    5,    1,    1,   201,    78,
        1497,  1487,   642,   651,
        493,   269,   133,    70,    60,    24,    2,    1,    1,    1,
        1065,   504,   312,   228,   178,   451,   352,
        351,   174,
      },
      {  693,   179,    63,    54,    8,    1,    1,   169,    78,
        1502,  1497,   580,   591,
        375,   186,    77,    35,    21,    4,    1,    1,    1,    1,
        1099,   533,   341,   253,   206,   542,   432,
        306,   164,
      },
      {  867,   263,   105,    96,    16,    2,    1,   152,    81,
        1435,  1439,   521,   525,
        270,   107,    32,    8,    3,    1,    1,    1,    1,    1,
        1085,   537,   361,   277,   223,   616,   549,
        258,   156,
      },
      {  1022,   385,   182,   207,    46,    7,    1,   158,    88,
        1290,  1318,   501,   502,
        184,    38,    6,    1,    1,    1,    1,    1,    1,    1,
        1023,   480,   345,   301,   232,   665,   661,
        210,   133,
      },
      {  1184,   555,   307,   457,   185,    44,    6,   115,    41,
        1236,  1253,   329,   340,
        32,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1017,   385,   316,   370,   246,   672,   788,
        85,    23,
      },
      /* AC Inter bias group 3 tables */
      {  502,   106,    33,    22,    1,    1,    1,   151,   132,
        1446,  1451,   502,   499,
        343,   181,    84,    42,    36,    16,    3,    1,    1,    1,
        1211,   661,   429,   312,   242,   637,   498,
        288,   156,
      },
      {  651,   147,    48,    35,    3,    1,    1,   145,   140,
        1419,  1420,   469,   466,
        281,   132,    56,    25,    18,    6,    1,    1,    1,    1,
        1175,   656,   435,   328,   260,   715,   556,
        252,   147,
      },
      {  749,   179,    59,    43,    4,    1,    1,   123,   135,
        1423,  1431,   413,   409,
        221,    95,    36,    15,    9,    2,    1,    1,    1,    1,
        1159,   658,   444,   340,   272,   782,   656,
        205,   124,
      },
      {  902,   243,    86,    67,    7,    1,    1,   114,   141,
        1385,  1385,   387,   383,
        178,    67,    22,    7,    4,    1,    1,    1,    1,    1,
        1096,   632,   434,   339,   277,   813,   735,
        171,   109,
      },
      {  1081,   337,   133,   112,    15,    1,    1,    92,   137,
        1350,  1349,   311,   309,
        115,    34,    8,    2,    1,    1,    1,    1,    1,    1,
        1016,   595,   418,   342,   283,   870,   883,
        114,    78,
      },
      {  1253,   467,   210,   205,    34,    3,    1,    80,   130,
        1318,  1313,   258,   260,
        68,    12,    2,    1,    1,    1,    1,    1,    1,    1,
        874,   516,   378,   330,   273,   877,  1000,
        72,    53,
      },
      {  1362,   626,   333,   423,   100,    10,    1,    73,   106,
        1311,  1313,   241,   231,
        31,    3,    1,    1,    1,    1,    1,    1,    1,    1,
        620,   368,   286,   302,   245,   814,  1127,
        34,    28,
      },
      {  1203,   743,   460,   774,   284,    36,    1,    13,    25,
        1956,  1961,   103,   106,
        3,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        248,   131,   149,   272,   165,   535,   813,
        3,    3,
      },

      /* AC Intra bias group 4 tables */
      {  599,   150,    55,    50,    9,    1,    1,   181,    19,
        1487,  1487,   625,   625,
        473,   271,   138,    74,    71,    42,    11,    1,    1,    1,
        1187,   591,   356,   239,   170,   351,   137,
        395,   194,
      },
      {  758,   209,    79,    74,    15,    2,    1,   147,    25,
        1514,  1514,   521,   520,
        334,   165,    74,    36,    30,    11,    1,    1,    1,    1,
        1252,   644,   409,   279,   211,   472,   203,
        318,   171,
      },
      {  852,   252,   100,    98,    20,    3,    1,   130,    26,
        1493,  1498,   481,   473,
        268,   123,    51,    23,    15,    3,    1,    1,    1,    1,
        1256,   652,   426,   294,   231,   543,   242,
        278,   156,
      },
      {  971,   309,   130,   136,    30,    5,    1,   113,    28,
        1458,  1467,   443,   435,
        215,    90,    31,    12,    5,    1,    1,    1,    1,    1,
        1232,   643,   426,   303,   243,   590,   300,
        235,   136,
      },
      {  1100,   399,   180,   206,    53,    9,    1,   101,    29,
        1419,  1425,   375,   374,
        158,    47,    10,    1,    1,    1,    1,    1,    1,    1,
        1193,   609,   426,   319,   256,   643,   383,
        166,   103,
      },
      {  1195,   505,   249,   326,    98,    20,    3,   102,    25,
        1370,  1356,   355,   347,
        104,    11,    1,    1,    1,    1,    1,    1,    1,    1,
        1100,   568,   381,   330,   261,   642,   466,
        105,    69,
      },
      {  1176,   608,   345,   559,   244,    57,    6,   110,    9,
        1370,  1332,   372,   367,
        29,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        859,   427,   269,   359,   375,   608,   451,
        35,    20,
      },
      {  1140,   613,   391,   797,   458,   180,    37,    2,    1,
        2037,  1697,    95,    31,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        360,    49,    23,   198,  1001,   719,   160,
        1,    1,
      },
      /* AC Inter bias group 4 tables */
      {  931,   272,   105,    96,    16,    1,    1,    91,    52,
        1481,  1489,   347,   349,
        174,    74,    28,    12,    8,    3,    1,    1,    1,    1,
        1247,   719,   490,   356,   279,   706,   363,
        187,   110,
      },
      {  1095,   358,   148,   143,    25,    3,    1,    74,    61,
        1439,  1457,   304,   302,
        127,    46,    15,    5,    3,    1,    1,    1,    1,    1,
        1138,   664,   469,   347,   282,   768,   487,
        139,    87,
      },
      {  1192,   423,   188,   189,    36,    4,    1,    64,    61,
        1457,  1475,   284,   282,
        106,    35,    10,    3,    1,    1,    1,    1,    1,    1,
        1078,   624,   440,   329,   264,   744,   507,
        117,    73,
      },
      {  1275,   496,   231,   258,    52,    6,    1,    53,    55,
        1458,  1470,   248,   245,
        77,    20,    5,    1,    1,    1,    1,    1,    1,    1,
        984,   576,   414,   323,   260,   771,   569,
        84,    54,
      },
      {  1377,   603,   302,   367,    87,    11,    1,    37,    52,
        1522,  1532,   207,   204,
        47,    8,    1,    1,    1,    1,    1,    1,    1,    1,
        840,   493,   366,   291,   231,   690,   636,
        52,    32,
      },
      {  1409,   708,   385,   529,   148,    24,    1,    23,    37,
        1672,  1670,   163,   162,
        22,    2,    1,    1,    1,    1,    1,    1,    1,    1,
        647,   364,   291,   262,   210,   574,   643,
        26,    14,
      },
      {  1348,   778,   481,   755,   245,    53,    4,    13,    19,
        2114,  2089,   141,   139,
        7,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        302,   183,   162,   181,   182,   344,   437,
        8,    3,
      },
      {  1560,   769,   410,   664,   243,    58,    1,    1,    1,
        3017,  2788,    17,    24,
        3,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        34,    16,    8,    55,   134,   105,    86,
        1,    1,
      },
   };

   public static final CodingMode[][] modeAlphabet = {
      /* Reserved for custom alphabet. */
      { CodingMode.MODES[0], CodingMode.MODES[0],
        CodingMode.MODES[0], CodingMode.MODES[0],
        CodingMode.MODES[0], CodingMode.MODES[0],
        CodingMode.MODES[0], CodingMode.MODES[0] },

      /* Last motion vector dominates */
      {   CodingMode.CODE_INTER_LAST_MV,    CodingMode.CODE_INTER_PRIOR_LAST,
          CodingMode.CODE_INTER_PLUS_MV,    CodingMode.CODE_INTER_NO_MV,
          CodingMode.CODE_INTRA,            CodingMode.CODE_USING_GOLDEN,
          CodingMode.CODE_GOLDEN_MV,        CodingMode.CODE_INTER_FOURMV },

      {   CodingMode.CODE_INTER_LAST_MV,    CodingMode.CODE_INTER_PRIOR_LAST,
          CodingMode.CODE_INTER_NO_MV,      CodingMode.CODE_INTER_PLUS_MV,
          CodingMode.CODE_INTRA,            CodingMode.CODE_USING_GOLDEN,
          CodingMode.CODE_GOLDEN_MV,        CodingMode.CODE_INTER_FOURMV },

      {   CodingMode.CODE_INTER_LAST_MV,    CodingMode.CODE_INTER_PLUS_MV,
          CodingMode.CODE_INTER_PRIOR_LAST, CodingMode.CODE_INTER_NO_MV,
          CodingMode.CODE_INTRA,            CodingMode.CODE_USING_GOLDEN,
          CodingMode.CODE_GOLDEN_MV,        CodingMode.CODE_INTER_FOURMV },

      {   CodingMode.CODE_INTER_LAST_MV,    CodingMode.CODE_INTER_PLUS_MV,
          CodingMode.CODE_INTER_NO_MV,      CodingMode.CODE_INTER_PRIOR_LAST,
          CodingMode.CODE_INTRA,            CodingMode.CODE_USING_GOLDEN,
          CodingMode.CODE_GOLDEN_MV,        CodingMode.CODE_INTER_FOURMV },

      /* No motion vector dominates */
      {   CodingMode.CODE_INTER_NO_MV,      CodingMode.CODE_INTER_LAST_MV,
          CodingMode.CODE_INTER_PRIOR_LAST, CodingMode.CODE_INTER_PLUS_MV,
          CodingMode.CODE_INTRA,            CodingMode.CODE_USING_GOLDEN,
          CodingMode.CODE_GOLDEN_MV,        CodingMode.CODE_INTER_FOURMV },

      {   CodingMode.CODE_INTER_NO_MV,      CodingMode.CODE_USING_GOLDEN,
          CodingMode.CODE_INTER_LAST_MV,    CodingMode.CODE_INTER_PRIOR_LAST,
          CodingMode.CODE_INTER_PLUS_MV,    CodingMode.CODE_INTRA,
          CodingMode.CODE_GOLDEN_MV,        CodingMode.CODE_INTER_FOURMV },

   };


   public static final int[] mbOrderMap = { 0, 2, 3, 1 };

   public static final int[][] blockOrderMap1 = {
      { 0, 1, 3, 2 },
      { 0, 2, 3, 1 },
      { 0, 2, 3, 1 },
      { 3, 2, 0, 1 }
   };

   public static final int[] loopFilterLimitValuesV1 = {
      30, 25, 20, 20, 15, 15, 14, 14,
      13, 13, 12, 12, 11, 11, 10, 10,
      9,  9,  8,  8,  7,  7,  7,  7,
      6,  6,  6,  6,  5,  5,  5,  5,
      4,  4,  4,  4,  3,  3,  3,  3,
      2,  2,  2,  2,  2,  2,  2,  2,
      0,  0,  0,  0,  0,  0,  0,  0,
      0,  0,  0,  0,  0,  0,  0,  0
   };

   public static final int[] loopFilterLimitValuesV2 = {
      30, 25, 20, 20, 15, 15, 14, 14,
      13, 13, 12, 12, 11, 11, 10, 10,
      9,  9,  8,  8,  7,  7,  7,  7,
      6,  6,  6,  6,  5,  5,  5,  5,
      4,  4,  4,  4,  3,  3,  3,  3,
      2,  2,  2,  2,  2,  2,  2,  2,
      2,  2,  2,  2,  2,  2,  2,  2,
      1,  1,  1,  1,  1,  1,  1,  1
   };

   public static final int[] modeUsesMC = { 0, 0, 1, 1, 1, 0, 1, 1 };

}